﻿using System;
using System.Collections.Generic;
using System.Text;

namespace KeyRemapper
{
    public class EnsureUniqueRandom
    {
        private Random _rnd;
        private List<int> _numbers;

        public EnsureUniqueRandom()
        {
            _rnd = new Random();
            _numbers = new List<int>();
        }
        public EnsureUniqueRandom(int seed)
        {
            _rnd = new Random(seed);
            _numbers = new List<int>();
        }

        public int Next(int min, int max)
        {
            lock (_numbers)
            {
                int number = _rnd.Next(min, max);
                while (_numbers.Contains(number))
                    number = _rnd.Next(min, max);
                _numbers.Add(number);
                return number;
            }
        }

    }
}
